# Maintainer: Frederik Schwan <freswa at archlinux dot org>
# Contributor: Christian Rebischke <chris.rebischke@archlinux.org>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Jonathan Wiersma <archaur at jonw dot org>

pkgname=virt-viewer
pkgver=11.0
pkgrel=2
pkgdesc='A lightweight interface for interacting with the graphical display of virtualized guest OS.'
arch=('loong64' 'x86_64')
url='https://gitlab.com/virt-viewer/virt-viewer'
license=('GPL')
depends=('gtk-vnc' 'libvirt' 'spice-gtk' 'libvirt-glib' 'libgovirt' 'vte3')
makedepends=('meson' 'intltool' 'spice-protocol' 'gobject-introspection' 'bash-completion')
replaces=('virtviewer')
options=('debug')
source=("https://virt-manager.org/download/sources/virt-viewer/virt-viewer-${pkgver}.tar.xz"{,.asc}
        'rest.diff')
b2sums=('41914a60361f0a47a0b0b54962d228ffaec67c6b69c664bb6fe683b7074dd5e2136d2bf3528b6e1b6b785cc4e337125fe16fdd94dd603dd42e8fde543931241a'
        'SKIP'
        '354ef316ad07df3273333cf4fad77671cfc0ce74be32bae92ae4d18dacc07402c15185ad7be01bae23bdd087ed1c56b2565c2ac53e1280726337a0fc0107108e')
validpgpkeys=('DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF') # Daniel P. Berrange

prepare() {
  cd virt-viewer-${pkgver}
  patch -Np1 -i ../rest.diff
}

build() {
  arch-meson virt-viewer-${pkgver} build \
    -D libvirt=enabled \
    -D vnc=enabled \
    -D spice=enabled \
    -D ovirt=enabled \
    -D vte=enabled \
    -D bash_completion=enabled \
    -D git_werror=disabled

  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "${pkgdir}"
}
